package com.totoro.tymapping.executor.slotparse.impl;

import com.totoro.tymapping.constants.StaticSystemVarConst;
import com.totoro.tymapping.enums.ConditionExecutorEnum;
import com.totoro.tymapping.executor.slotparse.SlotParseExecutor;
import eos.moe.dragoncore.DragonCore;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import java.util.List;
import java.util.Map;
import java.util.UUID;

/**
 * @author Totoro
 * @version 0.1.0
 * @date 2025/8/13 - 15:20
 * @description
 **/
public class DragonCoreExecutor implements SlotParseExecutor {
    @Override
    public Boolean execute(String slot, List<String> condition, Player player) {
        condition = getSlotCondition(condition);
        // 如果没有龙核依赖直接返回false
        if(! StaticSystemVarConst.dependentDragonCoreEnable) {
            return false;
        }
        String finalSlot = getFinalSlot(slot);
        // 获取当前玩家的龙核槽位缓存
        Map<UUID, Map<String, ItemStack>> cacheMap = DragonCore.getInstance().getMiscManager().getCacheMap();
        if(! cacheMap.containsKey(player.getUniqueId())) {
            return false;
        }
        Map<String, ItemStack> itemStackMap = cacheMap.get(player.getUniqueId());
        if(! itemStackMap.containsKey(finalSlot)) {
            return false;
        }
        ItemStack itemStack = itemStackMap.get(finalSlot);
        return doParseValue(condition, itemStack, player);
    }
}
